$(function(){
	/*
	 * 初始化注册时间筛选
	 */
	$('#reg-range').datepicker({
		format: 'yyyy-mm-dd',
		language: 'zh-CN'
	});	

	$('#date-filter-btn').on('click',function(){
		$('#date-filter-form').submit();
	});


	var $filterForms = $('#search-by-name,#date-filter-form');
	$filterForms.each(function(){
		$(this).validate({
			showErrors: function(errMap,errList) {
				for(var index in errList) {
					var curErr = errList[index];
					$(curErr.element).tooltip({
						title: curErr.message,
						trigger: 'nanual'
					}).tooltip('show');
				}		
			}
		});
	});

	/*
	 * 删除用户
	 */
	$('.user-delete-btn').on('click',function(){
		var $this = $(this);
		actionConfirm({
			msg: '确认删除这个用户吗？',
			confirm: function(){
				cAjax({
					url: 'del',
					type: 'get',
					data: {
						uid: $this.parents('tr').attr('data-user-id')
					},
					success: function(obj) {
						$this.parents('tr').addClass('deleted');
						$this.parent().html('<span class="label label-warning">已删除</span>');
					}
				});	
			}
		});	
	});

});
